home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / examples / conv < prev    next >
Text File  |  1994-03-27  |  314b  |  20 lines

  1. #
  2. # Simplistic convolution function.
  3. # x and y must be vectors...
  4. # No error checking.
  5. #
  6.  
  7. conv = function( x , y )
  8. {
  9.   local( X , Y , n, tmp );
  10.  
  11.   n = x.n + y.n - 1;
  12.   X = fft( x, n );
  13.   Y = fft( y, n );
  14.  
  15.   tmp = ifft( X .* Y );
  16.   if( type(x) == "real" && type(y) == "real") { tmp = real(tmp); }
  17.  
  18.   return tmp;
  19. };
  20.